﻿using ClumsyWords.Portable.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClumsyWords.Portable.ViewModel
{
    public class DataViewModel : BindableBase
    {
        public DataViewModel()
            : this(new ObservableCollection<CommonGroup<CommonGroup<TermProperties>>>())
        { }

        public DataViewModel(ObservableCollection<CommonGroup<CommonGroup<TermProperties>>> groups)
        {
            this.Groups = groups;
        }

        public ObservableCollection<CommonGroup<CommonGroup<TermProperties>>> Groups { get; set; }

        public CommonGroup<CommonGroup<TermProperties>> GetGroup(string key) 
        {
            return this.Groups.ToList().FirstOrDefault(g => g.Key == key);
        }

        private List<CommonGroup<TermProperties>> _searchResult;
        public List<CommonGroup<TermProperties>> SearchResult
        {
            get { return this._searchResult; }
            set { this.SetProperty(ref this._searchResult, value); }
        }

        public bool IsDataLoaded { get; set; }
    }
}
